#include "sccb.h"

void SCCB_Delay(void) {
}

void SCCB_Init(void) {

}

void SCCB_SDA_IN(void)  //SDA--PB11 ���
{
}

void SCCB_SDA_OUT(void)
{
}

void SCCB_Start(void) {

}

void SCCB_Stop(void) {

}

void SCCB_No_Ack(void) {

}

uint8_t SCCB_WR_Byte(uint8_t dat) {
    return 0;
}

uint8_t SCCB_RD_Byte(void) {
    return 0;
}

uint8_t SCCB_WR_Reg(uint8_t reg, uint8_t data) {
    uint8_t res = 0;
    LL_I2C_HandleTransfer(SCCB_I2C, SCCB_ID, LL_I2C_ADDRSLAVE_7BIT, 2, LL_I2C_MODE_AUTOEND,
                          LL_I2C_GENERATE_START_WRITE);
    while (!LL_I2C_IsActiveFlag_TXE(SCCB_I2C));
    LL_I2C_TransmitData8(SCCB_I2C, reg);
    while (!LL_I2C_IsActiveFlag_TXE(SCCB_I2C));
    LL_I2C_TransmitData8(SCCB_I2C, data);
    while (!LL_I2C_IsActiveFlag_TXE(SCCB_I2C));
    while (!LL_I2C_IsActiveFlag_STOP(SCCB_I2C));
    LL_I2C_ClearFlag_STOP(SCCB_I2C);
    return res;
}

uint8_t SCCB_RD_Reg(uint8_t reg) {
    uint8_t val = 0;
    while (LL_I2C_IsActiveFlag_BUSY(SCCB_I2C));
    LL_I2C_HandleTransfer(SCCB_I2C, SCCB_ID, LL_I2C_ADDRSLAVE_7BIT, 1, LL_I2C_MODE_AUTOEND,
                          LL_I2C_GENERATE_START_WRITE);
    while (!LL_I2C_IsActiveFlag_TXE(SCCB_I2C));
    LL_I2C_TransmitData8(SCCB_I2C, reg);
    while (!LL_I2C_IsActiveFlag_TXE(SCCB_I2C));
    while (!LL_I2C_IsActiveFlag_STOP(SCCB_I2C));
    LL_I2C_ClearFlag_STOP(SCCB_I2C);
    while (LL_I2C_IsActiveFlag_BUSY(SCCB_I2C));
    LL_I2C_HandleTransfer(SCCB_I2C, SCCB_ID | 0X01, LL_I2C_ADDRSLAVE_7BIT, 1, LL_I2C_MODE_AUTOEND,
                          LL_I2C_GENERATE_START_READ);
    while (!LL_I2C_IsActiveFlag_RXNE(SCCB_I2C));
    val = LL_I2C_ReceiveData8(SCCB_I2C);
    while (!LL_I2C_IsActiveFlag_STOP(SCCB_I2C));
    LL_I2C_ClearFlag_STOP(SCCB_I2C);
    return val;
}


























/************************************************************************************************/


//STM32H7����ģ��-HAL�⺯���汾
//DevEBox  ��Խ����
//�Ա����̣�mcudev.taobao.com
//�Ա����̣�shop389957290.taobao.com	


/************************************************************************************************/





